﻿using System.Configuration;
using System.Data;
using System.Windows;

namespace Wpf.Activation.Demo2
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var now = DateTime.Now;
            var duration = TimeSpan.FromDays(30);
            var licenseKey = ConfigurationManager.AppSettings["license"];

            if (new WinSerial().ShowDialog() == false)
            {
                if (!LicenseValidator.ValidateLicenseKey(licenseKey, now, duration))
                {
                    MessageBox.Show("授权无效");
                    Current.Shutdown();
                }
            }

            // todo:go on
        }
    }

}
